package com.sg.service.biz.framework.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import com.sg.common.util.RedisUtil;
import com.sg.dto.base.framework.req.*;
import com.sg.dto.biz.framework.req.*;
import com.sg.dto.biz.framework.res.*;
import com.sg.entity.HostType;
import com.sg.entity.HostTypeRecommend;
import com.sg.service.base.framework.MHostTypeRecommendService;
import com.sg.service.base.framework.MHostTypeService;
import com.sg.common.exception.Assert;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author ：
 * @version 1.0
 * @date ：
 */
@Service
public class HostTypeServiceImpl
        implements com.wicket.okrframework.biz.service.HostTypeService {

    @Resource
    private RedisUtil redisUtil;
    @Resource
    private MHostTypeService mHostTypeService;
    @Resource
    private MHostTypeRecommendService mHostTypeRecommendService;

    /**
     * D1-1查询宿主类型列表[839]
     * gen by moon at 11/4/2022, 11:05:29 PM
     */
    @Trace(operationName = "D1-1查询宿主类型列表")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public QueryHostTypeListRespDto queryHostTypeList(QueryHostTypeListReqDto reqDto) {


        List<HostType> listHostType_1 = new ArrayList<>();
//步骤0: 1-1-14查询宿主类型列表 - queryHostTypeList
        List<HostType> listHostType = new ArrayList<>();
        QueryHostTypeListReq queryHostTypeListReq = new QueryHostTypeListReq();
        if (reqDto != null) {
            queryHostTypeListReq.setHostTypeName(reqDto.getHostTypeName());//SimpleFieldAssign//sourceId:22315_1
            queryHostTypeListReq.setCategoryTypeCode(reqDto.getCategoryTypeCode());//SimpleFieldAssign//sourceId:22296_1
            queryHostTypeListReq.setPlatformData(reqDto.getPlatformData());//SimpleFieldAssign//sourceId:22299_1
            queryHostTypeListReq.setIsSystem(reqDto.getIsSystem());//SimpleFieldAssign//sourceId:22300_1
            queryHostTypeListReq.setSubjectLifeCycle(reqDto.getSubjectLifeCycle());//SimpleFieldAssign//sourceId:22303_1
            queryHostTypeListReq.setIsRecommend(reqDto.getIsRecommend());//SimpleFieldAssign//sourceId:22304_1
            queryHostTypeListReq.setIsArchive(reqDto.getIsArchive());//SimpleFieldAssign//sourceId:22305_1
            queryHostTypeListReq.setIsFreeze(reqDto.getIsFreeze());//SimpleFieldAssign//sourceId:22314_1
            queryHostTypeListReq.setTempFreezeStatus(reqDto.getTempFreezeStatus());//SimpleFieldAssign//sourceId:34293_1
            queryHostTypeListReq.setCreateInductionId(reqDto.getCreateInductionId());//SimpleFieldAssign//sourceId:34297_1
        }

        /*1-1-14查询宿主类型列表[104]   */

        listHostType = mHostTypeService.queryHostTypeList(queryHostTypeListReq);


        listHostType_1 = listHostType;

        QueryHostTypeListRespDto retData = new QueryHostTypeListRespDto();
        retData.setHostTypeList(listHostType_1.stream().map(item -> BeanUtil.toBean(item, HostTypeDto.class)).collect(Collectors.toList()));//objList-to-objLists//sourceId:22337_1


        return retData;
    }

    /**
     * D1-1查询宿主类型列表（边界）[1423]
     * gen by moon at 8/10/2022, 3:16:00 AM
     */
    @Trace(operationName = "D1-1查询宿主类型列表（边界）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public QueryHostTypeListBorderRespDto queryHostTypeListBorder(QueryHostTypeListBorderReqDto reqDto) {


        List<HostType> listHostType_1 = new ArrayList<>();
//步骤0: 1-1-14查询宿主类型列表 - queryHostTypeList
        List<HostType> listHostType = new ArrayList<>();
        QueryHostTypeListReq queryHostTypeListReq = new QueryHostTypeListReq();
        queryHostTypeListReq.setPlatformData("TRUE");//sourceId:33641_1
        queryHostTypeListReq.setSubjectLifeCycle("CURRENTLY_VALID");//sourceId:33645_1
        queryHostTypeListReq.setIsFreeze("FALSE");//sourceId:33648_1
        if (reqDto != null) {
            queryHostTypeListReq.setCategoryTypeCode(reqDto.getCategoryTypeCode());//sourceId:33638_1
        }

        /*1-1-14查询宿主类型列表[104]   */
        Assert.isNull(queryHostTypeListReq.getCategoryTypeCode(), "D1-1查询宿主类型列表（边界）-1-1-14查询宿主类型列表-宿主类型身份不能为空", false);
        listHostType = mHostTypeService.queryHostTypeList(queryHostTypeListReq);

        listHostType_1 = listHostType;

        QueryHostTypeListBorderRespDto retData = new QueryHostTypeListBorderRespDto();
        retData.setHostTypeList(listHostType_1.stream().map(item -> BeanUtil.toBean(item, HostTypeDto.class)).collect(Collectors.toList()));//sourceId:33651_1


        return retData;
    }

    /**
     * D1-1新增宿主类型[841]
     * gen by moon at 8/10/2022, 3:26:54 AM
     */
    @Trace(operationName = "D1-1新增宿主类型")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public AddHostTypeRespDto addHostType(AddHostTypeReqDto reqDto) {


        String string_1 = null;
//步骤0: 1-1-14新增宿主类型 - addHostType
        String string = null;
        HostType hostType = new HostType();
        if (reqDto != null) {
            hostType.setHostTypeCode(reqDto.getHostTypeCode());//sourceId:22171_1
            hostType.setHostTypeName(reqDto.getHostTypeName());//sourceId:22172_1
            hostType.setCategoryTypeCode(reqDto.getCategoryTypeCode());//sourceId:22173_1
            hostType.setSubjectLifeCycle(reqDto.getSubjectLifeCycle());//sourceId:22202_1
            hostType.setHostSurfaceCode(reqDto.getHostSurfaceCode());//sourceId:23766_1
            hostType.setIsSystem(reqDto.getIsSystem());//sourceId:22177_1
            hostType.setHostInputFieldCode(reqDto.getHostInputFieldCode());//sourceId:23767_1
            hostType.setInputTypeCode(reqDto.getInputTypeCode());//sourceId:23768_1
            hostType.setInputSurfaceCode(reqDto.getInputSurfaceCode());//sourceId:23769_1
            hostType.setPlatformData(reqDto.getPlatformData());//sourceId:22176_1
        }

        /*1-1-14新增宿主类型[101]   */
        Assert.isNull(hostType.getHostTypeCode(), "D1-1新增宿主类型-1-1-14新增宿主类型-宿主类型编码不能为空", false);
        Assert.isNull(hostType.getHostTypeName(), "D1-1新增宿主类型-1-1-14新增宿主类型-宿主类型名称不能为空", false);
        Assert.isNull(hostType.getCategoryTypeCode(), "D1-1新增宿主类型-1-1-14新增宿主类型-宿主类型身份不能为空", false);
        Assert.isNull(hostType.getSubjectLifeCycle(), "D1-1新增宿主类型-1-1-14新增宿主类型-主体生命周期不能为空", false);
        Assert.isNull(hostType.getIsSystem(), "D1-1新增宿主类型-1-1-14新增宿主类型-是否系统类型不能为空", false);
        Assert.isNull(hostType.getPlatformData(), "D1-1新增宿主类型-1-1-14新增宿主类型-是否平台数据不能为空", false);
        string = mHostTypeService.addHostType(hostType);

        string_1 = string;

        AddHostTypeRespDto retData = new AddHostTypeRespDto();
        if (string_1 != null) {
            retData.setHostTypeId(string_1);//sourceId:28309_1
        }


        return retData;
    }

    /**
     * D1-1修改宿主类型[842]
     * gen by moon at 8/10/2022, 3:26:55 AM
     */
    @Trace(operationName = "D1-1修改宿主类型")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public UpdateHostTypeRespDto updateHostType(UpdateHostTypeReqDto reqDto) {


        //步骤0: 1-1-14修改宿主类型 - updateHostType
        boolean bOOLEAN;
        HostType hostType = new HostType();
        if (reqDto != null) {
            hostType.setHostTypeId(reqDto.getHostTypeId());//sourceId:22189_1
            hostType.setHostTypeCode(reqDto.getHostTypeCode());//sourceId:22190_1
            hostType.setHostTypeName(reqDto.getHostTypeName());//sourceId:22191_1
            hostType.setCategoryTypeCode(reqDto.getCategoryTypeCode());//sourceId:22192_1
            hostType.setHostSurfaceCode(reqDto.getHostSurfaceCode());//sourceId:22193_1
            hostType.setHostInputFieldCode(reqDto.getHostInputFieldCode());//sourceId:22194_1
            hostType.setInputTypeCode(reqDto.getInputTypeCode());//sourceId:22196_1
            hostType.setInputSurfaceCode(reqDto.getInputSurfaceCode());//sourceId:22197_1
            hostType.setIsSystem(reqDto.getIsSystem());//sourceId:22195_1
            hostType.setSubjectLifeCycle(reqDto.getSubjectLifeCycle());//sourceId:22198_1
            hostType.setIsArchive(reqDto.getIsArchive());//sourceId:22200_1
        }

        /*1-1-14修改宿主类型[102]   */
        Assert.isNull(hostType.getHostTypeId(), "D1-1修改宿主类型-1-1-14修改宿主类型-宿主类型ID不能为空", false);
        bOOLEAN = mHostTypeService.updateHostType(hostType);


        UpdateHostTypeRespDto retData = new UpdateHostTypeRespDto();


        return retData;
    }

    /**
     * D1-1查询宿主类型详情[840]
     * gen by moon at 8/10/2022, 3:26:52 AM
     */
    @Trace(operationName = "D1-1查询宿主类型详情")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public QueryHostTypeDetailRespDto queryHostTypeDetail(QueryHostTypeDetailReqDto reqDto) {


        HostType hostType_1 = null;
//步骤0: 1-1-14查询宿主类型详情 - queryHostTypeDetail
        HostType hostType = null;
        QueryHostTypeDetailReq queryHostTypeDetailReq = new QueryHostTypeDetailReq();
        if (reqDto != null) {
            queryHostTypeDetailReq.setHostTypeId(reqDto.getHostTypeId());//sourceId:22219_1
            queryHostTypeDetailReq.setHostTypeCode(reqDto.getHostTypeCode());//sourceId:22220_1
        }

        /*1-1-14查询宿主类型详情[195]   */

        hostType = mHostTypeService.queryHostTypeDetail(queryHostTypeDetailReq);

        hostType_1 = hostType;

        QueryHostTypeDetailRespDto retData = new QueryHostTypeDetailRespDto();
        if (hostType_1 != null) {
            retData.setHostTypeId(hostType_1.getHostTypeId());//sourceId:22272_1
            retData.setHostTypeCode(hostType_1.getHostTypeCode());//sourceId:22273_1
            retData.setHostTypeName(hostType_1.getHostTypeName());//sourceId:22274_1
            retData.setCategoryTypeCode(hostType_1.getCategoryTypeCode());//sourceId:22275_1
            retData.setHostSurfaceCode(hostType_1.getHostSurfaceCode());//sourceId:22276_1
            retData.setHostInputFieldCode(hostType_1.getHostInputFieldCode());//sourceId:22277_1
            retData.setPlatformData(hostType_1.getPlatformData());//sourceId:22278_1
            retData.setIsSystem(hostType_1.getIsSystem());//sourceId:22279_1
            retData.setInputTypeCode(hostType_1.getInputTypeCode());//sourceId:22280_1
            retData.setInputSurfaceCode(hostType_1.getInputSurfaceCode());//sourceId:22281_1
            retData.setIsRecommend(hostType_1.getIsRecommend());//sourceId:22283_1
            retData.setIsFreeze(hostType_1.getIsFreeze());//sourceId:22293_1
            retData.setTempFreezeStatus(hostType_1.getTempFreezeStatus());//sourceId:28073_1
            retData.setIsArchive(hostType_1.getIsArchive());//sourceId:22284_1
            retData.setSubjectLifeCycle(hostType_1.getSubjectLifeCycle());//sourceId:22282_1
            retData.setOperationInductionId(hostType_1.getOperationInductionId());//sourceId:22285_1
            retData.setCreateInductionId(hostType_1.getCreateInductionId());//sourceId:22286_1
            retData.setReleaseInductionId(hostType_1.getReleaseInductionId());//sourceId:22287_1
            retData.setArchiveInductionId(hostType_1.getArchiveInductionId());//sourceId:22288_1
            retData.setOperateTime(hostType_1.getOperateTime());//sourceId:22289_1
            retData.setCreateTime(hostType_1.getCreateTime());//sourceId:22290_1
            retData.setReleaseTime(hostType_1.getReleaseTime());//sourceId:22291_1
            retData.setArchiveTime(hostType_1.getArchiveTime());//sourceId:22292_1
        }


        return retData;
    }

    /**
     * D1-1存档宿主类型推荐的业务场景	[1447]
     * gen by moon at 8/10/2022, 3:16:13 AM
     */
    @Trace(operationName = "D1-1存档宿主类型推荐的业务场景	")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public ArchiveArchiveHostTypeBizScnRespDto archiveArchiveHostTypeBizScn(ArchiveArchiveHostTypeBizScnReqDto reqDto) {


        //virtualUsage 1-1-21修改宿主类型推荐的业务场景  1306
        boolean bOOLEAN;
        HostTypeRecommend hostTypeRecommend = new HostTypeRecommend();
        hostTypeRecommend.setSubjectLifeCycle("ARCHIVING");//sourceId:34454_1_1306
        hostTypeRecommend.setIsArchive("TRUE");//sourceId:34455_1_1306
        if (reqDto != null) {
            hostTypeRecommend.setRecommendHostTypeRecordId(reqDto.getRecommendHostTypeRecordId());//sourceId:34453_1_1306
        }

        /*1-1-21修改宿主类型推荐的业务场景[1052]   */
        Assert.isNull(hostTypeRecommend.getRecommendHostTypeRecordId(), "D1-1存档宿主类型推荐的业务场景	-1-1-21修改宿主类型推荐的业务场景-推荐宿主类型记录ID不能为空", false);
        Assert.isNull(hostTypeRecommend.getSubjectLifeCycle(), "D1-1存档宿主类型推荐的业务场景	-1-1-21修改宿主类型推荐的业务场景-主体生命周期不能为空", false);
        Assert.isNull(hostTypeRecommend.getIsArchive(), "D1-1存档宿主类型推荐的业务场景	-1-1-21修改宿主类型推荐的业务场景-是否存档不能为空", false);
        bOOLEAN = mHostTypeRecommendService.updateHostTypeBizScn(hostTypeRecommend);


//virtualUsage 1-1-21查询宿主类型推荐到业务场景列表  1307
        List<HostTypeRecommend> listHostTypeRecommend = new ArrayList<>();
        QueryHostTypeBizScnListReq queryHostTypeBizScnListReq = new QueryHostTypeBizScnListReq();
        queryHostTypeBizScnListReq.setSubjectLifeCycle("CURRENTLY_VALID");//sourceId:34462_1_1307
        if (reqDto != null) {
            queryHostTypeBizScnListReq.setHostTypeId(reqDto.getHostTypeId());//sourceId:34458_1_1307
        }

        /*1-1-21查询宿主类型推荐到业务场景列表[1055] 查询宿主类型推荐到业务场景列表，返回条数如果=0，就执行下一步。  */
        Assert.isNull(queryHostTypeBizScnListReq.getHostTypeId(), "D1-1存档宿主类型推荐的业务场景	-1-1-21查询宿主类型推荐到业务场景列表-推荐的宿主类型ID不能为空", false);
        Assert.isNull(queryHostTypeBizScnListReq.getSubjectLifeCycle(), "D1-1存档宿主类型推荐的业务场景	-1-1-21查询宿主类型推荐到业务场景列表-主体生命周期不能为空", false);
        listHostTypeRecommend = mHostTypeRecommendService.queryHostTypeBizScnList(queryHostTypeBizScnListReq);


        if ((listHostTypeRecommend != null && listHostTypeRecommend != null && listHostTypeRecommend.size() == 0)) {
            //if(1-1-21查询宿主类型推荐到业务场景列表.宿主类型推荐到业务场景列表数据集条数 等于 0)  1308

            boolean bOOLEAN_1;
            HostType hostType = new HostType();
            hostType.setIsRecommend("FALSE");//sourceId:34478_1_1309
            if (reqDto != null) {
                hostType.setHostTypeId(reqDto.getHostTypeId());//sourceId:34477_1_1309
            }

            /*1-1-14修改宿主类型[102]   */
            Assert.isNull(hostType.getHostTypeId(), "D1-1存档宿主类型推荐的业务场景	-1-1-14修改宿主类型-宿主类型ID不能为空", false);
            Assert.isNull(hostType.getIsRecommend(), "D1-1存档宿主类型推荐的业务场景	-1-1-14修改宿主类型-是否推荐不能为空", false);
            bOOLEAN_1 = mHostTypeService.updateHostType(hostType);


//processBranchName:正常结束 ,processBranchId:1310

        }
//processBranchName:正常结束 ,processBranchId:1311

        ArchiveArchiveHostTypeBizScnRespDto retData = new ArchiveArchiveHostTypeBizScnRespDto();


        return retData;
    }

    /**
     * D1-1发布宿主类型推荐到业务场景[1138]
     * gen by moon at 8/10/2022, 3:14:38 AM
     */
    @Trace(operationName = "D1-1发布宿主类型推荐到业务场景")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public ReleaseHostTypeBizScnRespDto releaseHostTypeBizScn(ReleaseHostTypeBizScnReqDto reqDto) {


        //步骤0: 1-1-21修改宿主类型推荐的业务场景 - updateHostTypeBizScn
        boolean bOOLEAN;
        HostTypeRecommend hostTypeRecommend = new HostTypeRecommend();
        hostTypeRecommend.setSubjectLifeCycle("CURRENTLY_VALID");//sourceId:34392_1
        if (reqDto != null) {
            hostTypeRecommend.setRecommendHostTypeRecordId(reqDto.getRecommendHostTypeRecordId());//sourceId:34390_1
        }

        /*1-1-21修改宿主类型推荐的业务场景[1052]   */
        Assert.isNull(hostTypeRecommend.getRecommendHostTypeRecordId(), "D1-1发布宿主类型推荐到业务场景-1-1-21修改宿主类型推荐的业务场景-推荐宿主类型记录ID不能为空", false);
        Assert.isNull(hostTypeRecommend.getSubjectLifeCycle(), "D1-1发布宿主类型推荐到业务场景-1-1-21修改宿主类型推荐的业务场景-主体生命周期不能为空", false);
        bOOLEAN = mHostTypeRecommendService.updateHostTypeBizScn(hostTypeRecommend);


//步骤1: 1-1-14修改宿主类型 - updateHostType
        boolean bOOLEAN_1;
        HostType hostType = new HostType();
        hostType.setIsRecommend("TRUE");//sourceId:23509_1
        if (reqDto != null) {
            hostType.setHostTypeId(reqDto.getHostTypeId());//sourceId:23508_1
        }

        /*1-1-14修改宿主类型[102]   */
        Assert.isNull(hostType.getHostTypeId(), "D1-1发布宿主类型推荐到业务场景-1-1-14修改宿主类型-宿主类型ID不能为空", false);
        Assert.isNull(hostType.getIsRecommend(), "D1-1发布宿主类型推荐到业务场景-1-1-14修改宿主类型-是否推荐不能为空", false);
        bOOLEAN_1 = mHostTypeService.updateHostType(hostType);


        ReleaseHostTypeBizScnRespDto retData = new ReleaseHostTypeBizScnRespDto();


        return retData;
    }

    /**
     * D1-1查询宿主类型推荐的业务场景列表[860]
     * gen by moon at 8/26/2022, 3:11:51 PM
     */
    @Trace(operationName = "D1-1查询宿主类型推荐的业务场景列表")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public QueryHostTypeBizScnListRespDto queryHostTypeBizScnList(QueryHostTypeBizScnListReqDto reqDto) {


        List<HostTypeRecommend> listHostTypeRecommend_1 = new ArrayList<>();
//步骤0: 1-1-21查询宿主类型推荐到业务场景列表 - queryHostTypeBizScnList
        List<HostTypeRecommend> listHostTypeRecommend = new ArrayList<>();
        QueryHostTypeBizScnListReq queryHostTypeBizScnListReq = new QueryHostTypeBizScnListReq();
        if (reqDto != null) {
            queryHostTypeBizScnListReq.setHostTypeId(reqDto.getHostTypeId());//sourceId:27825_1
            queryHostTypeBizScnListReq.setIsArchive(reqDto.getIsArchive());//sourceId:34380_1
        }

        /*1-1-21查询宿主类型推荐到业务场景列表[1055]   */

        listHostTypeRecommend = mHostTypeRecommendService.queryHostTypeBizScnList(queryHostTypeBizScnListReq);

        listHostTypeRecommend_1 = listHostTypeRecommend;

        QueryHostTypeBizScnListRespDto retData = new QueryHostTypeBizScnListRespDto();
        retData.setHostTypeBizScnList(listHostTypeRecommend_1.stream().map(item -> BeanUtil.toBean(item, HostTypeBizScnDto.class)).collect(Collectors.toList()));//sourceId:31429_1


        return retData;
    }

    /**
     * D1-1新增宿主类型推荐到业务场景[854]
     * gen by moon at 10/28/2022, 8:45:22 PM
     */
    @Trace(operationName = "D1-1新增宿主类型推荐到业务场景")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public AddHostTypeBizScnRespDto addHostTypeBizScn(AddHostTypeBizScnReqDto reqDto) {


        String string_1 = null;
//virtualUsage 1-1-21新增宿主类型推荐到业务场景  1312
        String string = null;
        HostTypeRecommend hostTypeRecommend = new HostTypeRecommend();
        if (reqDto != null) {
            hostTypeRecommend.setHostTypeId(reqDto.getHostTypeId());//SimpleFieldAssign//sourceId:22610_1_1312
            hostTypeRecommend.setBizSceneId(reqDto.getBizSceneId());//SimpleFieldAssign//sourceId:22611_1_1312
            hostTypeRecommend.setBizSenceCode(reqDto.getBizSenceCode());//SimpleFieldAssign//sourceId:22612_1_1312
            hostTypeRecommend.setBizAppCode(reqDto.getBizAppCode());//SimpleFieldAssign//sourceId:388730_1_1312
            hostTypeRecommend.setSubjectLifeCycle(reqDto.getSubjectLifeCycle());//SimpleFieldAssign//sourceId:34359_1_1312
        }

        /*1-1-21新增宿主类型推荐到业务场景[1051]   */
        Assert.isNull(hostTypeRecommend.getHostTypeId(), "D1-1新增宿主类型推荐到业务场景-1-1-21新增宿主类型推荐到业务场景-推荐的宿主类型ID不能为空", false);
        Assert.isNull(hostTypeRecommend.getBizSceneId(), "D1-1新增宿主类型推荐到业务场景-1-1-21新增宿主类型推荐到业务场景-业务场景ID不能为空", false);
        Assert.isNull(hostTypeRecommend.getBizSenceCode(), "D1-1新增宿主类型推荐到业务场景-1-1-21新增宿主类型推荐到业务场景-业务场景编码不能为空", false);
        Assert.isNull(hostTypeRecommend.getBizAppCode(), "D1-1新增宿主类型推荐到业务场景-1-1-21新增宿主类型推荐到业务场景-业务应用标识不能为空", false);
        Assert.isNull(hostTypeRecommend.getSubjectLifeCycle(), "D1-1新增宿主类型推荐到业务场景-1-1-21新增宿主类型推荐到业务场景-主体生命周期不能为空", false);
        string = mHostTypeRecommendService.addHostTypeBizScn(hostTypeRecommend);


        string_1 = string;
        if ((reqDto != null && reqDto.getSubjectLifeCycle() != null && reqDto.getSubjectLifeCycle().equals("CURRENTLY_VALID") || reqDto != null && reqDto.getSubjectLifeCycle() != null && reqDto.getSubjectLifeCycle().equals("EDITING"))) {
            //if((D1-1新增宿主类型推荐到业务场景.主体生命周期 等于 当前有效 or D1-1新增宿主类型推荐到业务场景.主体生命周期 等于 正在编辑))  1314

            boolean bOOLEAN;
            HostType hostType = new HostType();
            hostType.setIsRecommend("TRUE");//sourceId:34558_1_1315
            if (reqDto != null) {
                hostType.setHostTypeId(reqDto.getHostTypeId());//SimpleFieldAssign//sourceId:34557_1_1315
            }

            /*1-1-14修改宿主类型[102]   */
            Assert.isNull(hostType.getHostTypeId(), "D1-1新增宿主类型推荐到业务场景-1-1-14修改宿主类型-宿主类型ID不能为空", false);
            Assert.isNull(hostType.getIsRecommend(), "D1-1新增宿主类型推荐到业务场景-1-1-14修改宿主类型-是否推荐不能为空", false);
            bOOLEAN = mHostTypeService.updateHostType(hostType);


//processBranchName:正常结束 ,processBranchId:1316

        }
//processBranchName:正常结束 ,processBranchId:1317

        AddHostTypeBizScnRespDto retData = new AddHostTypeBizScnRespDto();
        if (string_1 != null) {
            retData.setRecommendHostTypeRecordId(string_1);//SimpleFieldAssign//sourceId:34361_1
        }


        return retData;
    }

    /**
     * D1-1查询宿主类型推荐的业务场景列表（边界）[1101]
     * gen by moon at 10/27/2022, 4:02:37 PM
     */
    @Trace(operationName = "D1-1查询宿主类型推荐的业务场景列表（边界）")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public QueryHostTypeBizScnListBorderRespDto queryHostTypeBizScnListBorder(QueryHostTypeBizScnListBorderReqDto reqDto) {


        List<HostTypeRecommend> listHostTypeRecommend_1 = new ArrayList<>();
//步骤0: 1-1-21查询宿主类型推荐到业务场景列表 - queryHostTypeBizScnList
        List<HostTypeRecommend> listHostTypeRecommend = new ArrayList<>();
        QueryHostTypeBizScnListReq queryHostTypeBizScnListReq = new QueryHostTypeBizScnListReq();
        if (reqDto != null) {
            queryHostTypeBizScnListReq.setHostTypeId(reqDto.getHostTypeId());//SimpleFieldAssign//sourceId:23065_1
            queryHostTypeBizScnListReq.setSubjectLifeCycle(reqDto.getSubjectLifeCycle());//SimpleFieldAssign//sourceId:33354_1
            queryHostTypeBizScnListReq.setIsArchive(reqDto.getIsArchive());//SimpleFieldAssign//sourceId:395185_1
        }

        /*1-1-21查询宿主类型推荐到业务场景列表[1055]   */
        Assert.isNull(queryHostTypeBizScnListReq.getHostTypeId(), "D1-1查询宿主类型推荐的业务场景列表（边界）-1-1-21查询宿主类型推荐到业务场景列表-推荐的宿主类型ID不能为空", false);
        listHostTypeRecommend = mHostTypeRecommendService.queryHostTypeBizScnList(queryHostTypeBizScnListReq);


        listHostTypeRecommend_1 = listHostTypeRecommend;

        QueryHostTypeBizScnListBorderRespDto retData = new QueryHostTypeBizScnListBorderRespDto();
        retData.setHostTypeBizScnList(listHostTypeRecommend_1.stream().map(item -> item.getBizSceneId())
                .collect(Collectors.toList()));/*list-to-strings*///sourceId:32005_1


        return retData;
    }

    /**
     * D1查询业务场景下宿主类型列表[5005]
     * gen by moon at 11/5/2022, 6:21:52 PM
     */
    @Trace(operationName = "D1查询业务场景下宿主类型列表")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public QueryBizSceneHostTypeListRespDto queryBizSceneHostTypeList(QueryBizSceneHostTypeListReqDto reqDto) {


        List<HostType> listHostType_1 = new ArrayList<>();
        List<HostType> listHostType_3 = new ArrayList<>();
        if ((reqDto != null && reqDto.getBizSenceCode() != null || reqDto != null && reqDto.getBizAppCode() != null)) {
            //if((D1查询业务场景下宿主类型列表列表.业务场景编码 值不等于空  or D1查询业务场景下宿主类型列表列表.业务应用标识 值不等于空 ))  20981

            List<HostTypeRecommend> listHostTypeRecommend = new ArrayList<>();
            QueryHostTypeBizScnListReq queryHostTypeBizScnListReq = new QueryHostTypeBizScnListReq();
            queryHostTypeBizScnListReq.setIsArchive("FALSE");//sourceId:417729_1_20983
            if (reqDto != null) {
                queryHostTypeBizScnListReq.setBizSenceCode(reqDto.getBizSenceCode());//SimpleFieldAssign//sourceId:388763_1_20983
                queryHostTypeBizScnListReq.setBizAppCode(reqDto.getBizAppCode());//SimpleFieldAssign//sourceId:388768_1_20983
            }

            /*1-1-21查询宿主类型推荐到业务场景列表[1055]   */
            Assert.isNull(queryHostTypeBizScnListReq.getIsArchive(), "D1查询业务场景下宿主类型列表-1-1-21查询宿主类型推荐到业务场景列表-是否存档不能为空", false);
            listHostTypeRecommend = mHostTypeRecommendService.queryHostTypeBizScnList(queryHostTypeBizScnListReq);


            List<HostType> listHostType = new ArrayList<>();
            if (listHostTypeRecommend != null && !CollectionUtil.isEmpty(listHostTypeRecommend) && listHostTypeRecommend.size() > 0) {
                BatchQueryHostTypeReq batchQueryHostTypeReq = new BatchQueryHostTypeReq();
                batchQueryHostTypeReq.setHostTypeList(listHostTypeRecommend.stream().map(item -> item.getHostTypeId())
                        .collect(Collectors.toList()));/*list-to-strings*///sourceId:388754_1_20984
                batchQueryHostTypeReq.setSubjectLifeCycle("CURRENTLY_VALID");//sourceId:388759_1_20984
                if (reqDto != null) {
                    batchQueryHostTypeReq.setCategoryTypeCode(reqDto.getCategoryTypeCode());//SimpleFieldAssign//sourceId:388755_1_20984
                    batchQueryHostTypeReq.setPlatformData(reqDto.getPlatformData());//SimpleFieldAssign//sourceId:388756_1_20984
                    batchQueryHostTypeReq.setIsSystem(reqDto.getIsSystem());//SimpleFieldAssign//sourceId:388757_1_20984
                    batchQueryHostTypeReq.setIsRecommend(reqDto.getIsRecommend());//SimpleFieldAssign//sourceId:388758_1_20984
                }

                /*1-1-14批量查询宿主类型[5006]   */
                Assert.isNull(batchQueryHostTypeReq.getIsRecommend(), "D1查询业务场景下宿主类型列表-1-1-14批量查询宿主类型-是否推荐不能为空", false);
                Assert.isNull(batchQueryHostTypeReq.getSubjectLifeCycle(), "D1查询业务场景下宿主类型列表-1-1-14批量查询宿主类型-主体生命周期不能为空", false);
                listHostType = mHostTypeService.batchQueryHostType(batchQueryHostTypeReq);


                listHostType_1 = listHostType;
            }
//processBranchName:正常结束 ,processBranchId:20985

        } else if ((reqDto != null && reqDto.getBizSenceCode() == null && reqDto != null && reqDto.getBizAppCode() == null)) {
            //elseif((D1查询业务场景下宿主类型列表列表.业务场景编码 值等于空  and D1查询业务场景下宿主类型列表列表.业务应用标识 值等于空 ))  21124

            List<HostType> listHostType_2 = new ArrayList<>();
            QueryHostTypeListReq queryHostTypeListReq = new QueryHostTypeListReq();
            queryHostTypeListReq.setSubjectLifeCycle("CURRENTLY_VALID");//sourceId:417711_1_21125
            if (reqDto != null) {
                queryHostTypeListReq.setCategoryTypeCode(reqDto.getCategoryTypeCode());//SimpleFieldAssign//sourceId:417708_1_21125
                queryHostTypeListReq.setPlatformData(reqDto.getPlatformData());//SimpleFieldAssign//sourceId:417709_1_21125
                queryHostTypeListReq.setIsSystem(reqDto.getIsSystem());//SimpleFieldAssign//sourceId:417710_1_21125
                queryHostTypeListReq.setIsRecommend(reqDto.getIsRecommend());//SimpleFieldAssign//sourceId:417712_1_21125
            }

            /*1-1-14查询宿主类型列表[104]   */
            Assert.isNull(queryHostTypeListReq.getIsRecommend(), "D1查询业务场景下宿主类型列表-1-1-14查询宿主类型列表-是否推荐不能为空", false);
            Assert.isNull(queryHostTypeListReq.getSubjectLifeCycle(), "D1查询业务场景下宿主类型列表-1-1-14查询宿主类型列表-主体生命周期不能为空", false);
            listHostType_2 = mHostTypeService.queryHostTypeList(queryHostTypeListReq);


            listHostType_3 = listHostType_2;
//processBranchName:正常结束 ,processBranchId:21126

        }
        QueryBizSceneHostTypeListRespDto retData = new QueryBizSceneHostTypeListRespDto();
        //todo dong 未找到匹配生成策略,请检查生成策略retData.setHostTypeList(listHostType_1.getHostTypeId()||listHostType_3.getHostTypeId()/listHostType_1.getHostTypeCode()||listHostType_3.getHostTypeCode()/listHostType_1.getHostTypeName()||listHostType_3.getHostTypeName()/listHostType_1.getIsRecommend()||listHostType_3.getIsRecommend()/listHostType_1.getOperationInductionId()||listHostType_3.getOperationInductionId()/listHostType_1.getOperateTime()||listHostType_3.getOperateTime()),数据源项; to( ==>tableName:undefined, fieldEnname:hostTypeList ,uniqueId: 388775_1 uniqueSourceId:out_null_null) from (varName:undefined fieldundefined)
        if (CollectionUtil.isNotEmpty(listHostType_1)) {
            retData.setHostTypeList(listHostType_1.stream().map(data -> BeanUtil.toBean(data, HostTypeDto.class)).collect(Collectors.toList()));
        }

        if (CollectionUtil.isNotEmpty(listHostType_3)) {
            retData.setHostTypeList(listHostType_3.stream().map(data -> BeanUtil.toBean(data, HostTypeDto.class)).collect(Collectors.toList()));
        }


        return retData;
    }

    /**
     * D1-1删除宿主类型推荐的业务场景[5037]
     * gen by moon at 10/28/2022, 8:45:32 PM
     */
    @Trace(operationName = "D1-1删除宿主类型推荐的业务场景")
    @Tags({@Tag(key = "参数", value = "arg[0]"),
            @Tag(key = "返回值", value = "returnedObj")})
    @Transactional(rollbackFor = Exception.class)
    @Override
    public DeleteHostTypeBizScnRespDto deleteHostTypeBizScn(DeleteHostTypeBizScnReqDto reqDto) {


        //virtualUsage 1-1-21查询宿主类型推荐的业务场景详情  20498
        HostTypeRecommend hostTypeRecommend = null;
        QueryHostTypeBizScnDetailReq queryHostTypeBizScnDetailReq = new QueryHostTypeBizScnDetailReq();
        queryHostTypeBizScnDetailReq.setSubjectLifeCycle("EDITING");//sourceId:407160_1_20498
        if (reqDto != null) {
            queryHostTypeBizScnDetailReq.setRecommendHostTypeRecordId(reqDto.getRecommendHostTypeRecordId());//SimpleFieldAssign//sourceId:407156_1_20498
        }

        /*1-1-21查询宿主类型推荐的业务场景详情[1054]   */
        Assert.isNull(queryHostTypeBizScnDetailReq.getRecommendHostTypeRecordId(), "D1-1删除宿主类型推荐的业务场景-1-1-21查询宿主类型推荐的业务场景详情-推荐宿主类型记录ID不能为空", false);
        Assert.isNull(queryHostTypeBizScnDetailReq.getSubjectLifeCycle(), "D1-1删除宿主类型推荐的业务场景-1-1-21查询宿主类型推荐的业务场景详情-主体生命周期不能为空", false);
        hostTypeRecommend = mHostTypeRecommendService.queryHostTypeBizScnDetail(queryHostTypeBizScnDetailReq);
        Assert.isTrue(hostTypeRecommend == null || hostTypeRecommend.getRecommendHostTypeRecordId() == null, "返回值不能为空", false);


//virtualUsage 1-1-21删除宿主类型推荐到业务场景	  20499
        boolean bOOLEAN;
        String string = new String();
        if (reqDto != null) {
            string = reqDto.getRecommendHostTypeRecordId();
            ;//SimpleFieldAssign//sourceId:407139_1_20499
        }

        /*1-1-21删除宿主类型推荐到业务场景	[1053]   */
        Assert.isNull(string, "D1-1删除宿主类型推荐的业务场景-1-1-21删除宿主类型推荐到业务场景	-推荐宿主类型记录ID不能为空", false);
        bOOLEAN = mHostTypeRecommendService.deleteHostTypeBizScn(string);


//virtualUsage 1-1-21查询宿主类型推荐到业务场景列表  20500
        List<HostTypeRecommend> listHostTypeRecommend = new ArrayList<>();
        if (hostTypeRecommend != null) {
            QueryHostTypeBizScnListReq queryHostTypeBizScnListReq = new QueryHostTypeBizScnListReq();
            queryHostTypeBizScnListReq.setIsArchive("FALSE");//sourceId:407188_1_20500
            if (hostTypeRecommend != null) {
                queryHostTypeBizScnListReq.setHostTypeId(hostTypeRecommend.getHostTypeId());//SimpleFieldAssign//sourceId:407185_1_20500
            }

            /*1-1-21查询宿主类型推荐到业务场景列表[1055]   */
            Assert.isNull(queryHostTypeBizScnListReq.getHostTypeId(), "D1-1删除宿主类型推荐的业务场景-1-1-21查询宿主类型推荐到业务场景列表-推荐的宿主类型ID不能为空", false);
            Assert.isNull(queryHostTypeBizScnListReq.getIsArchive(), "D1-1删除宿主类型推荐的业务场景-1-1-21查询宿主类型推荐到业务场景列表-是否存档不能为空", false);
            listHostTypeRecommend = mHostTypeRecommendService.queryHostTypeBizScnList(queryHostTypeBizScnListReq);


        }
        if ((listHostTypeRecommend != null && listHostTypeRecommend != null && listHostTypeRecommend.size() == 0)) {
            //if(1-1-21查询宿主类型推荐到业务场景列表.宿主类型推荐到业务场景列表数据集条数 等于 0)  20501

            boolean bOOLEAN_1;
            if (hostTypeRecommend != null) {
                HostType hostType = new HostType();
                hostType.setIsRecommend("FALSE");//sourceId:407179_1_20502
                if (hostTypeRecommend != null) {
                    hostType.setHostTypeId(hostTypeRecommend.getHostTypeId());//SimpleFieldAssign//sourceId:407178_1_20502
                }

                /*1-1-14修改宿主类型[102]   */
                Assert.isNull(hostType.getHostTypeId(), "D1-1删除宿主类型推荐的业务场景-1-1-14修改宿主类型-宿主类型ID不能为空", false);
                Assert.isNull(hostType.getIsRecommend(), "D1-1删除宿主类型推荐的业务场景-1-1-14修改宿主类型-是否推荐不能为空", false);
                bOOLEAN_1 = mHostTypeService.updateHostType(hostType);


            }
//processBranchName:正常结束 ,processBranchId:20503

        }
        DeleteHostTypeBizScnRespDto retData = new DeleteHostTypeBizScnRespDto();


        return retData;
    }
    //
}
